<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>瑞吉外卖管理端</title>
  <link rel="shortcut icon" href="/backend/favicon.ico">
  <!-- 引入样式 -->
  <link rel="stylesheet" href= "/backend/plugins/element-ui/index.css" />
  <link rel="stylesheet" href="/backend/styles/common.css">
  <link rel="stylesheet" href="/backend/styles/login.css">
  <link rel="stylesheet" href="/backend/styles/icon/iconfont.css" />
  <style>
    .body{
      min-width: 1366px;
    }
  </style>
</head> 

<body>

  <div class="login" id="login-app">
    <div class="login-box">
      <img src="/backend/images/login/login-l.png" alt="">
      <div class="login-form">
        <el-form ref="loginForm" :model="postForm" :rules="loginRules" >
          <div class="login-form-title">
            <img src="/backend/images/login/logo.png" style="width:139px;height:42px;" alt="" />
          </div>
          <el-form-item prop="password">
            <el-input v-model="postForm.password" type="password" placeholder="重置密码" prefix-icon="iconfont icon-lock" maxlength="20"
                       />
          </el-form-item>
          <el-form-item prop="password">
            <el-input v-model="postForm.passwords" type="password" placeholder="确认密码" prefix-icon="iconfont icon-lock" maxlength="20"
               />
          </el-form-item>
          <el-form-item style="width:100%;">
            <el-button :loading="loading" class="login-btn" size="medium" type="primary" style="width:100%;"
              @click.native.prevent="submit">
              <span v-if="!loading">提交</span>
            </el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>

  <!-- 开发环境版本，包含了有帮助的命令行警告 -->
  <script src="/backend/plugins/vue/vue.js"></script>
  <!-- 引入组件库 -->
  <script src="/backend/plugins/element-ui/index.js"></script>
  <!-- 引入axios -->
  <script src="/backend/plugins/axios/axios.min.js"></script>
  <script src="/backend/js/request.js"></script>
  <script src="/backend/js/validate.js"></script>
  <script src="/backend/api/login.js"></script>
  <script src="/backend/js/request.js"></script>
  <script src="/backend/js/validate.js"></script>
  <script src="/backend/api/login.js"></script>
  <script>
    new Vue({
      el: '#login-app',
      data() {
        return {
          postForm:{
            username: '',
            email: '',
            password: '',
            passwords: ''
          },
          loading: false
        }
      },
      computed: {
        loginRules() {
          const validatePassword = (rule, value, callback) => {
            if (value.length < 6 ) {
              callback(new Error('密码必须在6位以上'))
            } else {
              callback()
            }
          }
          const validatePasswords = (rule, value, callback) => {
            if (value == validatePassword) {
              callback(new Error('两次密码必须一致'))
            } else {
              callback()
            }
          }
          return {
            'username': [{ 'validator': validatePassword, 'trigger': 'blur' }],
            'password': [{ 'validator': validatePasswords, 'trigger': 'blur' }]
          }
        }
      },
      created() {
          this.getCookie()
      },
      methods: {
        getCookie() {
          if (document.cookie.length > 0) {
            var arr = document.cookie.split('; '); //这里显示的格式需要切割一下自己可输出看下

            for (var i = 0; i < arr.length; i++) {
              var arr2 = arr[i].split('%='); //再次切割
              //判断查找相对应的值
              if (arr2[0] == 'key') {
                this.$nextTick(()=>{
                  //dom元素更新后执行，此时能拿到p元素的属性
                  this.postForm.email = arr2[1]; //保存到保存数据的地方
                })
              }
            }
          }
        },
        submit(){
          var _this =this;
          return $axios({
            'url':'/employee/findpwd',
            'method': 'post',
            data: {
              'email': _this.postForm.email,
              'password': _this.postForm.password
            }
          })
        }
      }
    })
  </script>
</body>

</html>
